package com.doliere.android.app.p2p.activities;

import com.doliere.android.app.p2p.services.P2pService;

import android.os.Bundle;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.Intent;
import android.view.Menu;
import android.view.View;

public class MainActivity extends Activity {
	
	P2pService service;
	Intent mServiceIntent;
	private ContentResolver mContentResolver;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//0findViewById(R.id.button1).setEnabled(false);
		setContentView(R.layout.activity_main);
	}
	
	@Override
	protected void onStart(){
		super.onStart();
	}
	
	@Override
	protected void onPause(){
		super.onPause();
	}
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	
	public void stopService(View view){
		if(mServiceIntent != null)
			stopService(mServiceIntent);
		findViewById(R.id.button2).setEnabled(true);
		findViewById(R.id.button1).setEnabled(false);
		
	}
	
	public void startService(View view){
		service = new P2pService();
	    mServiceIntent = new Intent(this, service.getClass());
		startService(mServiceIntent);
		findViewById(R.id.button2).setEnabled(false);
		findViewById(R.id.button1).setEnabled(true);
	}
	
	public void displayPeers(View view){
		if(mServiceIntent != null && service != null){
			mContentResolver = getContentResolver();
			mContentResolver.acquireContentProviderClient("PEERS_DATA");
		}
	}

}
